package org.example.platform.design.singleton;


import static org.apache.tomcat.jni.Lock.lock;

/**
 * 单例模式
 */
public class SingletionLock {
    private static SingletionLock singletion;

    /**
     * 程序运行时创建一个静态只读的进程辅助对象
     */
//    private static readonly Object syncObject = new Object();

    private SingletionLock() {
        // 构造方法私有化，防止外界利用new创建该类实例
    }

    public static SingletionLock getInstance() {
        // 双重锁定
        if (singletion == null) {
//            lock(syncObject) {
                if (singletion == null) {
                    singletion = new SingletionLock();
                }
//            }
        }
        return singletion;
    }
}
